<?php defined('IN_LK') or die('Access Denied');
/**
 * Lk controller控制器基类
 * @category    Lk
 * @package     Lk
 * @subpackage core
 * @author     <yangzhiguo0903@163.com>
 * @version    $Id$
 */
class controller
{
	public function __construct()
	{
		$param = load_class('param', 'core');
		$params = $param->get();
		define('M', $params['m']);
		define('C', $params['c']);
		define('A', $params['a']);
		$this->initialize();
	}

   /**
    * 调用控制器类中的方法
	* 禁止调用私有属性
    */
	private function initialize()
	{
		$controller = $this->load_controller();
		if(method_exists($controller, A) && is_callable(array($controller, A)))
		{
			call_user_func(array($controller, A));
		}
		else
		{
			show_error('Call Undefined Action ' . A);
		}
	}

   /**
    * 调用控制器
	*/
	private function load_controller()
	{
		$classname = C;
		$path = APP_PATH . 'controllers' . S . M . S . $classname . '.class.php';
		if(is_file($path))
		{
			include $path;
			if(class_exists($classname))
			{
				return new $classname;
			}
		}
		show_error('Call Undefined Controller ' . $classname);
	}
}
// End controller class
/* End of file controller.class.php */
/* Location: ./system/core/controller.class.php */